package com.FH.organization.Attachment;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2016/10/17.
 */
@Path("/attachment")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class AttachmentResource {

    @EJB
    private AttachmentDAO attachmentDAO;

    @GET
    @Path("/{apply}&{page}&{size}")
    public ResultDTO getAttachmentInfo(@PathParam("apply") String apply, @PathParam("page") String page, @PathParam("size") String size) {

        //添加分页查询
        if (null == page || "".equals(page) || "0".equals(page)) {
            page = "1";    //默认从第0行开始查起
        }
        if (null == size || "".equals(size)) {
            size = "10";  //每页默认10条数据
        }
        return attachmentDAO.getAttachmentInfo(apply, page, size);

    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteAttachmentInfo(AttachmentPullDTO attachmentPullDTO) {

        return attachmentDAO.deleteAttachmentInfo(attachmentPullDTO);
    }
}
